- @title = @parent_folder.try(:name) || t('.heading')

- if @parent_folder && @parent_folder.all_groups.any?
  .alert.alert-warning
    = icon('fa fa-lock')
    = t('documents.restricted_folder.alert_html', |
      groups: @parent_folder.all_groups.map { |g| link_to(g.name, g) }.join(', ').html_safe)

- if @parent_folder
  - if @parent_folder.hidden?
    .alert.alert-warning
      = icon('fa fa-eye-slash')
      = t('documents.hidden_folder.alert')
  - elsif @parent_folder.hidden_at_all?
    .alert.alert-warning
      = icon('fa fa-eye-slash')
      = t('documents.hidden_folder_due_to_parent.alert')

%p
  = @parent_folder.try(:description) || t('.intro')

.btn-group.pull-right
  = link_to documents_path(folder_id: params[:folder_id], view: 'detail'), class: @view == 'detail' ? 'btn btn-primary' : 'btn btn-default' do
    = icon 'fa fa-bars'
  = link_to documents_path(folder_id: params[:folder_id], view: 'thumbnail'), class: @view == 'thumbnail' ? 'btn btn-primary' : 'btn btn-default' do
    = icon 'fa fa-th-large'

- if @logged_in.admin?(:manage_documents)
  = form_tag nil, method: 'get', id: 'document-visibility' do
    = hidden_field_tag 'folder_id', params[:folder_id]
    %ul.list-unstyled
      - if @hidden_folder_count > 0
        %li
          = check_box_tag :hidden_folders, true, @show_hidden_folders, class: 'simple'
          = label_tag :hidden_folders, t('documents.index.hidden_folders.label', count: @hidden_folder_count)
      - if @restricted_folder_count > 0
        %li
          = check_box_tag :restricted_folders, true, @show_restricted_folders, class: 'simple'
          = label_tag :restricted_folders, t('documents.index.restricted_folders.label', count: @restricted_folder_count)

- if @folders.any? or @documents.any?
  - if @view == 'detail'
    = render 'details'
  - else
    = render 'thumbnails'
- else
  %em= t('none')

- if @logged_in.admin?(:manage_documents)
  .page-controls.push-down
    - if @logged_in.admin?(:manage_documents) && @parent_folder
      .pull-right
        = link_to edit_document_path(@parent_folder, folder: true), class: 'btn btn-info' do
          = icon 'fa fa-pencil'
          = t('.edit_folder.button')
        = link_to document_path(@parent_folder, folder: true), data: { method: 'delete', confirm: t('documents.delete_folder.confirmation') }, class: 'btn btn-delete' do
          = icon 'fa fa-trash-o'
          = t('.delete_folder.button')
    = link_to new_document_path(folder: true, folder_id: @parent_folder), class: 'btn btn-success' do
      = icon 'fa fa-folder'
      = t('.new_folder.button')
    = link_to new_document_path(folder_id: @parent_folder), class: 'btn btn-success' do
      = icon 'fa fa-file'
      = t('.new_document.button')
